package com.example.demo.controller;


import com.example.demo.entity.RegisterEntity;
import com.example.demo.result.Result;
import com.example.demo.result.ResultUtil;
import com.example.demo.service.impl.RegisterServiceImpl;
import com.example.demo.util.FileUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
public class UploadController {

    @Autowired
    private RegisterServiceImpl registerService;

//    @RequestParam

    @PostMapping("/uploadImg")
    public Result uploadImg( @RequestParam   MultipartFile file,String serialNumber) throws IOException {
        String url = FileUtil.uploadImg(file,serialNumber);
        registerService.insertUrl(url,serialNumber);
        return ResultUtil.success(url);
    }
}
